﻿using System;
using System.Collections.Generic;
using Missbot.Service;

namespace Missbot.AIModule.OnlineStore
{
    public class DriftBottleItemModel
    {
        public string Name { get; set; }

        public string Description { get; set; }

        public int Rate { get; set; }

        public int Price { get; set; }

        public string[] Attributes { get; set; }

        public int Exp => Price / 10;
    }

    public class DriftBottleHonor : DbBaseEntity
    {
        public int Year { get; set; }

        public int Month { get; set; }
        
        public string Name { get; set; }

        public List<DriftBottleItemModel> Items { get; set; }

        public bool IsLimit { get; set; }
    }

    public static class DriftBottleHonorDA
    {
        public static List<DriftBottleHonor> Get()
        {
            return MongoService<DriftBottleHonor>.Get();
        }
        
        public static string FullName(this DriftBottleHonor entity)
        {
            return entity.IsLimit ? $"{entity.Name}({entity.Year}{entity.Month:00}限定)" : entity.Name;
        }

        public static string SortKey(this DriftBottleHonor entity)
        {
            return $"{entity.Year}{entity.Month:00}";
        }

        public static bool IsCurLimit(this DriftBottleHonor entity)
        {
            return entity.IsLimit && DateTime.Now.Year == entity.Year && DateTime.Now.Month == entity.Month;
        }

        public static void Update(this DriftBottleHonor entity)
        {
            MongoService<DriftBottleHonor>.Update(entity);
        }

        public static void Insert(this DriftBottleHonor entity)
        {
            MongoService<DriftBottleHonor>.Insert(entity);
        }
    }
}